package com.arron.juc;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;

public class LockSupportDemo {


    public static void main(String[] args) throws InterruptedException {

        AtomicInteger i = new AtomicInteger(0);

        Thread t1 = new Thread(() -> {
            System.out.println("开始暂定");
            LockSupport.park();
            System.out.println("被唤醒执行业务。。。。");
            i.set(1);
        }, "A");

        t1.start();
        //主线程睡眠5S
        Thread.sleep(5000);


        //唤醒线程1
        LockSupport.unpark(t1);

        while (i.get() == 0){

        }


        System.out.println("主线程结束。。");

    }
}
